#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: HJ28.py 
@version:
@time: 2023/05/22 
"""
import math


def check(num):
    for i in range(2, int(math.sqrt(num)) + 2):
        if num % i == 0:
            return False
    return True


def find(odd, visited, choose, evens):
    for j, even in enumerate(evens):
        if check(odd + even) and not visited[j]:
            visited[j] = True
            if choose[j] == 0 or find(choose[j], visited, choose, evens):
                choose[j] = odd
                return True
    return False


while True:
    try:
        num = int(input())
        a = list(map(int, input().split()))
        count = 0

        odds = []
        evens = []
        for i in a:
            if i % 2 == 0:
                odds.append(i)
            else:
                evens.append(i)

        choose = [0] * len(evens)
        for odd in odds:
            visited = [False] * len(evens)
            if find(odd, visited, choose, evens):
                count += 1
        print(count)
    except:
        break
